l1 = ['R a in',  'C ats',  'and',  'Do g']
l2 = []
# 用空格进行分割，再拼接
for i in l1:
    j = i.split()
    jo=''
    l2.append(jo.join(j))
print(l2)

# 用空值替换空格的方法
for i in range(len(l1)):
    # if ' ' in l1[i]:
    l1[i] = l1[i].replace(' ','')
print(l1)